<template>
  <div class="form-box">
    <el-form ref="user" :model="params" label-width="120px" :rules="rules">
      <el-form-item label="注册时间" prop="createTime">
        <el-input class="form-input" v-model="form.createTime" disabled />
      </el-form-item>
      <el-form-item label="设备号" prop="deviceId">
        <el-input class="form-input" v-model="form.deviceId" disabled />
      </el-form-item>
      <el-form-item label="身份证姓名" prop="name">
        <el-input class="form-input" v-model="params.name" disabled/>
      </el-form-item>
      <el-form-item label="身份证号" prop="idCard">
        <el-input class="form-input" v-model="params.idCard" disabled/>
      </el-form-item>
<!--      <el-form-item label="身份证正面">-->
<!--        <el-image-->
<!--          style="width: 100px; height: 100px"-->
<!--          :src="form.idCardImg1"-->
<!--          :preview-src-list="[form.idCardImg1]"></el-image>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="身份证反面">-->
<!--        <el-image-->
<!--          style="width: 100px; height: 100px"-->
<!--          :src="form.idCardImg2"-->
<!--          :preview-src-list="[form.idCardImg2]"></el-image>-->
<!--      </el-form-item>-->
      <el-form-item label="UID" prop="id">
        <el-input class="form-input" v-model="form.id" disabled />
      </el-form-item>
      <el-form-item label="昵称" prop="nickName">
        <el-input class="form-input" v-model="params.nickName" :disabled="!checkPermi(['member:manager:nickname'])"/>
      </el-form-item>
      <el-form-item label="手机号码" prop="phone">
        <el-input class="form-input" v-model="form.phone" disabled />
      </el-form-item>
      <el-form-item label="填写邀请码" prop="inviteCode">
        <el-input class="form-input" v-model="params.inviteCode" disabled />
      </el-form-item>
      <el-form-item label="现金账户金额" prop="cashAmount">
        <el-input class="form-input" v-model="form.appUserAccCash.cashAmount" disabled />
      </el-form-item>
      <el-form-item label="冻结保证金" prop="freezeAmount">
        <el-input class="form-input" v-model="form.appUserAccCash.freezeAmount" disabled />
      </el-form-item>
      <el-form-item label="消费券余额" prop="goldAmount">
        <el-input class="form-input" v-model="form.appUserAccConsume.consumeAmount" disabled />
      </el-form-item>
      <el-form-item label="金积分账户余额" prop="goldAmount">
        <el-input class="form-input" v-model="form.appUserAccIntegral.goldAmount" disabled />
      </el-form-item>

      <el-form-item label="银积分账户余额" prop="silverAmount">
        <el-input class="form-input" v-model="form.appUserAccIntegral.silverAmount" disabled />
      </el-form-item>
      <el-form-item label="佣金账户余额" prop="brokerageAmount">
        <el-input class="form-input" v-model="form.appUserAccBrokerage.brokerageAmount" disabled />
      </el-form-item>
      <el-form-item label="信用指数" prop="artExponent" v-if="checkPermi(['memeber:look:artExponent'])">
        <el-input class="form-input" v-model="form.appUserArtist.artExponent" disabled />
      </el-form-item>
      <el-form-item label="VIP等级" prop="vipLevel">
        <el-select v-model="form.vipLevel" clearable style="width: 100%" disabled>
          <el-option v-for="dict in vipLevel" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
        <!-- <el-input class="form-input" v-model="form.vipLevelStr" disabled /> -->
      </el-form-item>
      <el-form-item label="VIP有效期" prop="vipEndTime">
        <el-input class="form-input" v-model="form.vipEndTime" disabled />
      </el-form-item>
      <el-form-item label="管理员用户" prop="adminUser">
        <el-select v-model="params.adminUser" placeholder="是否是管理员" clearable style="width: 100%" :disabled="!checkPermi(['member:manager:nickname'])">
          <el-option v-for="dict in adminUser" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { updateUser } from "@/api/vip/vip.js";
import { checkPermi } from "@/utils/permission"; // 权限判断函数

export default {
  name: 'FormView',
  props: {
    form: {
      type: Object,
    },
  },

  data() {
    return {
      adminUser: [{ label: '是', value: 1 }, { label: '否', value: 0 }],
      params: {
        id: this.form.id,
        nickName: this.form.nickname,
        adminUser: this.form.adminUser,
        inviteCode: this.form.inviteCode,
        name: this.form.name,
        idCard: this.form.idCard
      },
      vipLevel: [{ label: '普通用户', value: 0 }, { label: '有效会员', value: 1 }, { label: '银牌会员', value: 2 }, { label: '金牌会员', value: 3 }],

      rules: {
        name: [{ required: true, message: "身份证姓名必填", trigger: "change" }],
        idCard: [{ required: true, message: "身份证号必填", trigger: "change" }],
        nickname: [{ required: true, message: "昵称必填", trigger: "change" }],
        inviteCode: [{ required: true, message: "邀请码必填", trigger: "change" }],
        adminUser: [{ required: true, message: "", trigger: "change" }],
      }
    }
  },
  created() {
  },

  mounted() {
    // this.$bus.$on('updataUser', this.updateUser)
  },

  destroyed() {

    // this.$bus.$off('updataUser')

  },

  methods: {
    checkPermi,
    // updateUser(block) {
    //   this.params.id = this.form.id;
    //   this.params.nickName = this.form.nickname;
    //   this.params.adminUser = this.form.adminUser;
    //   this.params.inviteCode = this.form.inviteCode;
    // }
  }
}
</script>

<style lang="scss" scoped>
.form-box {
  max-height: 55vh;
  overflow-y: scroll;
}
.el-dialog-div {
  padding-right: 30px;
}
.table-box {
  margin-left: 40px;
}
</style>
